/**
 * 
 */
package com.doone.telmarket.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.doone.telmarket.domain.ServiceProduct;

/**
 * @author 吴同庆
 * @date 2009-10-21
 * @description
 * @package com.doone.telmarket.vo
 */
public class ServiceOrderRelationResult implements Serializable {
	
	private static final long serialVersionUID = 5865192916436043513L;
	
	private String resultCode;
	
	private String message;
	
	private List<String> productIdList = new ArrayList<String>();
	
	private List<ServiceProduct> serviceProductList = new ArrayList<ServiceProduct>();
	
	public ServiceOrderRelationResult(String resultCode,String message){
		this.resultCode = resultCode;
		this.message = message;
	}
	
	public List<String> getProductIdList() {
		return productIdList;
	}

	public void setProductIdList(List<String> productIdList) {
		this.productIdList = productIdList;
	}

	public List<ServiceProduct> getServiceProductList() {
		return serviceProductList;
	}

	public void setServiceProductList(List<ServiceProduct> serviceProductList) {
		this.serviceProductList = serviceProductList;
	}

	public void addProductId(String productId){
		productIdList.add(productId);
	}
	
	public void removeProductId(String productId){
		productIdList.remove(productId);
	}

	public String getResultCode() {
		return resultCode;
	}

	public String getMessage() {
		return message;
	}
	
	public int getProductIdCount(){
		return productIdList.size();
	}
	
	public void addServiceProductList(List<ServiceProduct> serviceProductList){
		this.serviceProductList = serviceProductList;
	}
	
	public int getServiceProductCount(){
		return this.serviceProductList.size();
	}
	
	public ServiceProduct getServiceProduct(int index){
		return this.serviceProductList.get(index);
	}
	
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("resultCode:");
		buffer.append(getResultCode());
		buffer.append("message:");
		buffer.append(getMessage());
		buffer.append("productId:");
		for (String productId : productIdList) {
			buffer.append(productId);
			buffer.append(",");
		}
		return buffer.toString();
	}
	
	public String toQueryParame(){
		StringBuffer buffer = new StringBuffer();
		for (String productId : productIdList) {
			buffer.append(productId);
			buffer.append(",");
		}
		return StringUtils.substring(buffer.toString(), 0, buffer.toString().length()-1);
	}
	
	
	public static void main(String[] args){
		ServiceOrderRelationResult result = new ServiceOrderRelationResult("0", "成功");
		result.addProductId("1111111");
		result.addProductId("2222222");
		result.addProductId("33333333");
		System.out.println(result.toQueryParame());
	}
	
	

}
